
package org.puremvc.as3.multicore.demos.flex.hellopipes.modules.simplemodule.controller
{

    import org.puremvc.as3.multicore.demos.flex.hellopipes.modules.simplemodule.model.MessagesProxy;
    import org.puremvc.as3.multicore.demos.flex.hellopipes.modules.simplemodule.view.SimpleModuleJunctionMediator;
    import org.puremvc.as3.multicore.demos.flex.hellopipes.modules.simplemodule.view.SimpleModuleMediator;
    import org.puremvc.as3.multicore.interfaces.ICommand;
    import org.puremvc.as3.multicore.interfaces.INotification;
    import org.puremvc.as3.multicore.patterns.command.SimpleCommand;
    import org.puremvc.as3.multicore.patterns.facade.Facade;

	/**
	 * Disposes all core actors to avoid issues loading this module again
	 * which means remove all references, listeners etc.
	 * for a successful garbage collection
	 */
    public class DisposeCommand extends SimpleCommand implements ICommand
    {
        override public function execute(note:INotification):void
        {
			// remove Mediators to force its onRemove() method
			// for unregistering event listeners, disconnecting pipes etc.
 			facade.removeMediator( SimpleModuleJunctionMediator.NAME );
       		facade.removeMediator( SimpleModuleMediator.NAME );
       		//
       		// remove proxy
       		facade.removeProxy( MessagesProxy.NAME );
       		//
       		// remove all core actors registerd of this key
       		Facade.removeCore( SimpleModule.NAME );
       		
       		
        }
        
    }
}